package com.jml.juc.fork;


import com.jml.juc.TTTFork;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.RecursiveTask;

/**
 *
 */

public class ForkJoinTaskBoot extends RecursiveTask<Boolean> {

    private  WorkFork workFork =null;
    private  List<RecursiveTask> list =null;

    public ForkJoinTaskBoot(WorkFork workFork) {
        this.workFork = workFork;
        this.list = workFork.getReList();
    }


    //将大任务分解成小任务
    @Override
    public Boolean compute() {
        for (RecursiveTask recursiveTask: list) {
            recursiveTask.fork();
        }
        for (RecursiveTask lt : list) {
            String join = (String)lt.join();
            System.out.println("任务返回"+join);
        }
        return true;
    }
}

